<template>
	<view class="receive">
		<view class="nav">
			<u-tabs :list="list1" lineColor="#FF5B1A" :activeStyle="{color: '#FF5B1A'}" @click="change" :scrollable="false"></u-tabs>
		</view>
		<scroll-view scroll-y="true" class="main" @scrolltolower="lower()">
			<view class="list" v-for="(item,index) of list" @click="detail(item.sametask.id)">
				<view class="l">
					<view class="title">{{item.name}}</view>
					<view class="info">
						<view class="other">时间:</view>
						<view class="con">{{item.sametask.starttime | date('yyyy年mm月dd日')}}</view>
					</view>
					<view class="info">
						<view class="other">佣金:</view>
						<view class="con"><view class="moeny">{{item.price}}元</view></view>
					</view>
					<view class="info">
						<view class="other">人数:</view>
						<view class="con"><view class="num">{{item.sametask.acceptnum}}</view>/{{item.sametask.num}}</view>
					</view>
					<view class="info">
						<view class="other">联系人:</view>
						<view class="con">{{item.sametask.username}} {{item.sametask.mobile}}</view>
					</view>
				</view>
				<view class="r">
					<view class="status" v-if="type> 0">已完成</view>
					<view class="status" v-else>服务中</view>
					<image :src="oss(item.sametask.images)" class="cover" mode=""></image>
					<view class="give" @click="cancel(item.id)">放弃</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list1: [{
					name: '服务中',
					type: 0
				}, {
					name: '已完成',
					type: 1
				}],
				
				page: 1,
				finish: false,
				type: 0,
				list: [],
				show3: false,
				note: '',
				id: ''
			}
		},
		onLoad(options) {
			this.id = options.id
			this.getList()
		},
		methods: {
			detail(id) {
				uni.$u.route({
					url: 'pagesA/index/detail',
					params: {
						id: id
					}
				})
			},
			cancel(id) {
				uni.$u.http.post('/acceptcity', {
					id: id,
					types: 'cancel'
				}).then(res => {
					if (res.code == 1) {
						uni.$u.toast(res.msg)
						this.reload()
					}
				}).catch((res) => {
						
				})
			},
			tel(mobile) {
				uni.makePhoneCall({
					phoneNumber: mobile
				});
			},
			toast(note) {
				this.note = note
				this.show3 = true
			},
			change(e) {
				console.log(e)
				this.type = e.type
				this.reload()
			},
			reload() {
				this.page = 1
				this.finish = false
				this.list = []
				this.getList()
			},
			lower() {
				this.page++
				this.getList()
			},
			getList() {
				if (this.finish) {
					return
				}
				uni.$u.http.post('/acceptcity', {
					page: this.page,
					type: this.type
				}).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.list = this.list.concat(res.data)
						if (res.data.length === 0) {
							this.finish = true
						}
					}
				}).catch((res) => {
		
				})
			}
		}
	}
</script>

<style lang="scss">
	.receive {
		height: 100vh;
		position: relative;
		background-color: #F6F6F6;
		.nav{
			display: flex;
			align-items: center;
			justify-content: center;
			flex-shrink: 0;
		}
		.main{
			position: absolute;
			left: 0;
			width: 100%;
			bottom: 0;
			top: 90rpx;
			padding-top: 20rpx;
			overflow: hidden;
		}
		.list{
			display: flex;
			margin: 0 20rpx 10rpx;
			padding: 20rpx;
			background-color: #fff;
			border-radius: 10rpx;
			align-items: center;
			position: relative;
			.l{
				flex: 1;
				.title{
					color: #191615;
					font-size: 36rpx;
				}
				.info{
					display: flex;
					align-items: center;
					margin-top: 10rpx;
					.other{
						color: #999999;
						font-size: 28rpx;
						margin-right: 10rpx;
					}
					.con{
						color: #575859;
						font-size: 28rpx;
						display: flex;
						align-items: center;
						.moeny{
							color: #FF5B1A;
						}
						.num{
							color: #428DFC;
						}
					}
				}
			}
			.r{
				display: flex;
				flex-direction: column;
				align-items: flex-end;
				.status{
					color: #428DFC;
					font-weight: bold;
					font-size: 30rpx;
				}
				.cover{
					width: 188rpx;
					height: 154rpx;
					margin: 10rpx 0;
				}
				.give{
					color: #999999;
					font-size: 28rpx;
				}
			}
		}
	}
</style>
